package com.woniu.gym.controller;


import com.woniu.core.util.PageInfo;
import com.woniu.core.util.Result;
import com.woniu.gym.dto.CoachJobApplicationDto;
import com.woniu.gym.dto.RecruitConditionDto;
import com.woniu.gym.form.AddRecruitForm;
import com.woniu.gym.form.FindAllJobForm;
import com.woniu.gym.form.FindJobByGymNumForm;
import com.woniu.gym.form.ModifyRecruitForm;
import com.woniu.gym.model.TRecruitCondition;
import com.woniu.gym.service.TRecruitConditionService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.Map;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 吴彦祖
 * @since 2024年04月02日
 */
@RestController
@RequestMapping("/tRecruitCondition")
@Api(tags = "发布招聘信息相关接口")
public class TRecruitConditionController {
    @Resource
    private TRecruitConditionService tRecruitConditionService;
    @ApiOperation("发布招聘信息")
    @PostMapping("/addRecruit.gym")
    public Result<RecruitConditionDto> addRecruit(@Valid @RequestBody AddRecruitForm form){
        RecruitConditionDto dto = tRecruitConditionService.addRecruit(form);
        return Result.getResult(RecruitConditionDto.class).setMsg("发布成功").setData(dto);
    }

    @ApiOperation("根据recruitId删除招聘信息")
    @GetMapping("/delJobPostings.gym")
        public Result<TRecruitCondition> delJobPostings(Integer recruitId,String gymNum){
        TRecruitCondition recruitCondition =  tRecruitConditionService.delJobPostings(recruitId,gymNum);
        return Result.getResult(TRecruitCondition.class).setMsg("删除成功").setData(recruitCondition);
    }

    @ApiOperation("根据场馆gymNum分页查询自己的招聘信息")
    @GetMapping ("/findJobByGymNum.gym")
    public Result findJobPostingsById(FindJobByGymNumForm form){
        PageInfo<RecruitConditionDto> dto = tRecruitConditionService.findJobPostingsById(form);
        return Result.getResult(PageInfo.class).setMsg("查询成功").setData(dto);
    }
    @ApiOperation("教练查询所有的招聘信息")
    @GetMapping ("/findAllJob.coach")
    public Result findAllJob(FindAllJobForm form){
        PageInfo<RecruitConditionDto> dto = tRecruitConditionService.findAllJob(form);
        return Result.getResult(PageInfo.class).setMsg("查询成功").setData(dto);
    }
    @ApiOperation("修改招聘信息")
    @PostMapping("/modifyRecruit.gym")
    public Result<Boolean> modifyRecruit(@Valid @RequestBody ModifyRecruitForm form){
        tRecruitConditionService.modifyRecruit(form);
        return Result.getResult(Boolean.class).setMsg("发布成功").setData(true);
    }

}

